package com.hursing.tractor.view;

import android.graphics.Rect;

import com.hursing.tractor.baseview.UIView;

public final class UIStatusPanelView extends UIView {
	
	private static int mSecondLeft;
	
	@Override
	public UIView layout(int w, int h) {
		final int firstTop = (int) (h * 0.01);
		final int firstBottom = (int) (h * 0.07);
		final int firstLeft = (int) (w * 0.01);
		final int secondTop = (int) (h * 0.08);
		final int secondBottom = (int) (h * 0.14);
		final int secondRight = (int) (w * 0.99);
		mFrame = new Rect(firstLeft, firstTop, secondRight, secondBottom);
		
		int width = sViews[VIEW_MASTER_LABEL].measureWidth();
		int right = firstLeft + width;
		sViews[VIEW_MASTER_LABEL].frame(new Rect(firstLeft, firstTop, right, firstBottom));
		width = sViews[VIEW_CURRENT_MASTER_LABEL].measureWidth();
		sViews[VIEW_CURRENT_MASTER_LABEL].frame(new Rect(right, firstTop, right + width, firstBottom));
		
		width = sViews[VIEW_FLIPPER_LABEL].measureWidth();
		right = firstLeft + width;
		sViews[VIEW_FLIPPER_LABEL].frame(new Rect(firstLeft, secondTop, right, secondBottom));
		width = sViews[VIEW_CURRENT_FLIPPER_LABEL].measureWidth();
		sViews[VIEW_CURRENT_FLIPPER_LABEL].frame(new Rect(right, secondTop, right + width, secondBottom));
		// score比house长，先算score
		width = (int) sViews[VIEW_SCORE_LABEL].measureWidth();
		if (mSecondLeft == 0) {
			mSecondLeft = secondRight - width - (int) sViews[VIEW_CURRENT_SCORE_LABEL].measureWidth();
		}
		right = mSecondLeft + width;
		sViews[VIEW_SCORE_LABEL].frame(new Rect(mSecondLeft, secondTop, right, secondBottom));
		sViews[VIEW_CURRENT_SCORE_LABEL].frame(new Rect(right, secondTop, secondRight, secondBottom));
		
		width = (int) sViews[VIEW_HOUSE_LABEL].measureWidth();
		right = mSecondLeft + width;
		sViews[VIEW_HOUSE_LABEL].frame(new Rect(mSecondLeft, firstTop, right, firstBottom));
		sViews[VIEW_CURRENT_HOUSE_LABEL].frame(new Rect(right, firstTop, secondRight, firstBottom));
		
		sViews[VIEW_FLIPPED_SUIT].frame(new Rect(sViews[VIEW_CURRENT_FLIPPER_LABEL].frame().right, secondTop, 0, secondBottom));
		width = sViews[VIEW_FLIPPED_SUIT].measureWidth();
		sViews[VIEW_FLIPPED_SUIT].frame().right = sViews[VIEW_FLIPPED_SUIT].frame().left + width;
		
		return this;
	}
}
